<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增岗位')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-post-add" enctype="multipart/form-data" th:object="${post}">
			<input type="hidden" name="id" th:field="*{id}">
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">货品编码：</label>
				<div class="col-sm-8">
					<input class="form-control" th:field="*{codingId}" type="text" name="codingId" id="postName" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">货品名称：</label>
				<div class="col-sm-8">
					<input class="form-control" th:field="*{name}" type="text" name="name" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">成本价格：</label>
				<div class="col-sm-8">
					<input class="form-control" th:field="*{costsPrice}" type="text" name="costsPrice" id="postSort" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">销售价格：</label>
				<div class="col-sm-8">
					<input class="form-control" th:field="*{salePrice}" type="text" name="salePrice" id="salePrice" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">货品品牌：</label>
				<div class="col-sm-8">
				    <div class="radio-box" th:each="dict : ${@dict.getType('sys_brand_type')}">
						<input type="radio" th:field="*{brand}" th:id="${dict.dictCode}" name="brand" th:value="${dict.dictValue}" th:checked="${dict.default}">
						<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">货品图片：</label>
				<div class="col-sm-8">
					<input type="file" name="img">
					<img  th:src="*{'../../upload/'+img}" width="50px">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">货品备注：</label>
				<div class="col-sm-8">
					<textarea id="remark" th:field="*{remark}" name="remark" class="form-control"></textarea>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "system/product";
		function submitHandler() {
	        if ($.validate.form()) {
	        //	$.operate.save(prefix + "/add", $('#form-post-add').serialize());
				var bpmnFile=  $('[name="img"]')[0].files[0];
				if (!bpmnFile){
					$.modal.alertWarning("请选择文件")
					return;
				}
				//发送AJaX 文件
				var fd=new FormData();
				fd.append("bpmnFile",bpmnFile);
				var par=$('#form-post-add').serialize();
				par=decodeURIComponent(par)
				fd.append('product',par)
				console.log(par)
				$.ajax({
					url:prefix+'/edit',
					type:'post',
					data:fd,
					processData:false,
					contentType:false,
					success:function (data) {
						$.operate.successCallback(data);
					}
				})
	        }
	    }
	</script>
</body>
</html>
